﻿//Hien thi cac can bo cua mot don vi
function show_staff_of_unit(){
	var v_count = document.all.tr_staff.length;
	for(var i =0; i < v_count; i++){
		if(document.all.tr_staff[i].unit_id == document.forms(0).sel_unit(document.forms(0).sel_unit.selectedIndex).id){
			document.all.tr_staff[i].style.display = 'block';
		}else{
			document.all.tr_staff[i].style.display = 'none';
		}
	}		
}
//Ham them can bo vao trong danh sach nhung nguoi co quyen tra loi cau hoi
function add_list_onclick(p_checkbox_obj, p_hidden_obj, p_fuseaction){
	if (!checkbox_value_to_list(p_checkbox_obj,"!&~$*")){
		alert("Chưa có đối tượng được chọn");
	}else{
		document.forms(0).fuseaction.value = p_fuseaction;
		p_hidden_obj.value = checkbox_value_to_list(p_checkbox_obj,"!&~$*");
		document.forms(0).submit(); 	
	}
}
function btn_save_answerer_qa_onclick(p_agency_checkbox_list_obj,p_cate_checkbox_list_obj,p_hdn_agency_checkbox_list_obj, p_hdn_cate_checkbox_list_obj, p_fuseaction){
	p_hdn_agency_checkbox_list_obj.value = checkbox_value_to_list(p_agency_checkbox_list_obj,"!&~$*");
	p_hdn_cate_checkbox_list_obj.value = checkbox_value_to_list(p_cate_checkbox_list_obj,"!&~$*");
	btn_save_onclick(p_fuseaction);
}
function sel_change_onclick(p_select_obj,p_hidden_obj) {
	var v_unit_id = document.forms(0).sel_unit(document.forms(0).sel_unit.selectedIndex).id;
	p_hidden_obj.value = p_select_obj.value ;
	if (v_unit_id > 0){
		try{
			var v_count = document.all.tr_staff.length;
			if(v_count){
				for(var i =0; i < v_count; i++){
					if(document.all.tr_staff[i].unit_id ==  v_unit_id ){
						document.all.tr_staff[i].style.display = 'block';
					}else{
						document.all.tr_staff[i].style.display = 'none';
					}
				}
			}else{
				if(document.all.tr_staff.unit_id ==  v_unit_id ){
						document.all.tr_staff.style.display = 'block';
				}else{
					document.all.tr_staff.style.display = 'none';
				}
			}
		}
		catch(e){;}
	}else{
		document.forms(0).submit();
	}
}
